import { defineConfig  , loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path';

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd());

  return {
    plugins: [vue()],
    define: {
      "process.env": env,
    },
    server: {
      proxy: {
        '/api': {
          target: 'http://localhost:3000',
          timeout: 100000, // 10 秒超时
          changeOrigin: true,
        }
      }
    },
    root: './',  // 确保 Vite 以 `client/` 目录为根目录
    build: {
      outDir: 'dist',  // 打包后文件存放目录
    },
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'),
      }
    },
  };
});